using Contacts.Maui.Models;
using ContactModels = Contacts.Maui.Models.Contact;

namespace Contacts.Maui.Views;

public partial class TestPage : ContentPage
{
    private ContactModels _contact;

    public TestPage()
    {
        InitializeComponent();
    }

    protected override void OnAppearing()
    {
        base.OnAppearing();

        _contact = ContactRepository.GetContactsById(1);
        this.EntryName.Text = _contact.Name;
        this.EntryEmail.Text = _contact.Email;
        this.EntryPhone.Text = _contact.Phone;
        this.EntryAdress.Text = _contact.Adress;
    }

    private void SaveButton_Clicked(object sender, EventArgs e)
    {
        _contact.Name = this.EntryName.Text;
        _contact.Email = this.EntryEmail.Text;
        _contact.Phone = this.EntryPhone.Text;
        _contact.Adress = this.EntryAdress.Text;
        ContactRepository.UpdateContacts(_contact.ContactId, _contact);
    }
}